/**
 * UI布局控件
 * @author wyajun[wyajun@slof.com]
 */
function Layout(o){
	this.editor = o;
}

Layout.prototype.toString = function(){
	return "Layout";
}

/**
 * 设置某个panle的title
 */
Layout.prototype.setPanelTitle = function(region,title){
	var $editor = jQuery(this.editor);
	var pl =  $editor.layout('panel',region);
	pl.panel("setTitle",title);
}
/**
 * 重设置某个panel的链接地址
 * @param {Object} region
 * @param {Object} href
 */
Layout.prototype.setPanelHref = function(region,href){
	var $editor = jQuery(this.editor);
	var pl =  $editor.layout('panel',region);
	var opts = pl.panel("options");
	opts.href = href;
	pl.panel("refresh");
	
}

/**
 * 初始化布局
 */
Layout.prototype.onReady = function(){
    var $editor = jQuery(this.editor);
	var id = $editor.attr("id");	
	//执行布局组件函数
	using('layout', function(){
		$editor.layout({});
	});
	
	//处理有时组件显示高度没有填充整个父容器（或窗体）
	var self = this;
	jQuery(window).bind("resize", function(){
        self.resize();
        $editor.height(document.body.clientHeight);
    })
	
}
/**
 * 缩回指定区域
 * @param {} region
 */
Layout.prototype.collapse = function(region){
    var $editor = jQuery(this.editor);
    $editor.layout('collapse',region);
}

/**
 * 展开指定区域
 */
Layout.prototype.expand = function(region){
	var $editor = jQuery(this.editor);
	$editor.layout('expand',region);
}

Layout.prototype.resize = function(){
	var $editor = jQuery(this.editor);
    $editor.layout('resize');
}